import requests
import app

# 操作员工的接口
class EmployeeAPI:
    # 初始化
    def __init__(self):
        self.url_add_employee = app.BASE_URL+"/api/sys/user"
        self.url_update_employee = app.BASE_URL+"/api/sys/user/{}"
        self.url_find_employee = app.BASE_URL+"/api/sys/user/{}"
        self.url_delete_employee = app.BASE_URL+"/api/sys/user/{}"


    # 添加员工
    def add_employee(self, add_employee_data):
        return requests.post(url=self.url_add_employee, json=add_employee_data, headers=app.Headers_data)

    # 修改员工
    def update_employee(self, employee_id, update_employee_data):
        url = self.url_update_employee.format(employee_id)
        return requests.put(url=url, json=update_employee_data, headers=app.Headers_data)

    # 查询员工
    def find_employee(self, employee_id):
        url = self.url_find_employee.format(employee_id)
        return requests.get(url=url, headers=app.Headers_data)

    # 删除员工
    def delete_employee(self, employee_id):
        url = self.url_delete_employee.format(employee_id)
        return requests.delete(url=url, headers=app.Headers_data)
